home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / flex-2.4.6 / MISC / fastwc / wc1.l < prev    next >
Encoding:
Text File  |  1994-07-23  |  247 b   |  19 lines  |  [TEXT/KAHL]

  1. /* First cut at a flex-based "wc" tool. */
  2.  
  3. ws    [ \t]
  4. nonws [^ \t\n]
  5.  
  6. %%
  7.     int cc = 0, wc = 0, lc = 0;
  8.  
  9. {nonws}+    cc += yyleng; ++wc;
  10.  
  11. {ws}+        cc += yyleng;
  12.  
  13. \n        ++lc; ++cc;
  14.  
  15. <<EOF>>        {
  16.         printf( "%8d %8d %8d\n", lc, wc, cc );
  17.         yyterminate();
  18.         }
  19.